﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.Infrastructure.Common;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WCS.Domain.ScGetWMSTaskDomain;
using Zocono.WCS.Domain.WorkTaskDomain;
using Zocono.WCS.Infrastructure.ApllicationDto;
using Zocono.WCS.Infrastructure.ApllicationDto.WCSTaskDto;
using Zocono.WCS.Infrastructure.ApllicationDto.WmsModel;


namespace Zocono.WCS.Application.AppConfigureManage
{
    public class WorkTaskInfoApp
    {
        private readonly IWorkTaskInfoServeice _WorkTaskInfoServeice;
        private readonly IScGetWMSTaskService _IScGetWMSTaskService;
        public WorkTaskInfoApp(IWorkTaskInfoServeice workTaskInfoServeice, IScGetWMSTaskService scGetWMSTaskService)
        {
            _WorkTaskInfoServeice = workTaskInfoServeice;
            _IScGetWMSTaskService = scGetWMSTaskService;
        }

        public async Task<PageDto<WCSWorkTaskInfoDto>> GetPagedWorkTaskInfoAsync(QueryWorkTaskInfoDto queryWorkTaskInfoDto)
        {
            return await _WorkTaskInfoServeice.GetPagedWorkTaskInfoAsync(queryWorkTaskInfoDto);
        }
        public async Task<PageDto<WCSWorkTaskInfoDto>> GetPagedCurrentWorkTaskInfoAsync(QueryWorkTaskInfoDto queryWorkTaskInfoDto)
        {
            return await _WorkTaskInfoServeice.GetPagedCurrentWorkTaskInfoAsync(queryWorkTaskInfoDto);
        }
        
        public async Task<WorkTaskInfo> GetWorkTaskByIdAsync(long id)
        {
            return await _WorkTaskInfoServeice.GetWorkTaskInfoByIdAsync(id);
        }

        public async Task<bool> UpdataWorkTaskByTaskAsync(WorkTaskInfo workTaskInfo)
        {
            return await _WorkTaskInfoServeice.UpdataWorkTaskInfoByTask(workTaskInfo);
        }
        public async Task<bool> DelWorkTaskAsync(long id)
        {
            return await _WorkTaskInfoServeice.DelWorkTaskInfAsync(id);
        }

        public async Task<bool> ScUpdateWorkTaskInfoAsync(WCSWorkTaskInfoDto wCSWorkTaskInfoDto)
        {
            return await _IScGetWMSTaskService.ScUpdateWorkTaskInfoAsync(wCSWorkTaskInfoDto);
        }

        public async Task<bool> InsertTaskRouteDetailRecordInfoAsync(TaskRouteDetailRecordInfo taskRouteDetailRecordInfo)
        {
            return await _IScGetWMSTaskService.InsertTaskRouteDetailRecordInfoAsync(taskRouteDetailRecordInfo);
        }


        public async Task<RouteDetailInfo> GetNextRouteDetailInfoByIdAsync(long Id)
        {
            return await _IScGetWMSTaskService.GetNextRouteDetailInfoByIdAsync(Id);
        }


        public async Task<bool> ScUpdateWorkTaskInfoRouteDetailAsync(WCSWorkTaskInfoDto wCSWorkTaskInfoDto)
        {
            return await _IScGetWMSTaskService.ScUpdateWorkTaskInfoRouteDetailAsync(wCSWorkTaskInfoDto);
        }



        public async Task<PlcWriteDbInfo> ScGetPlcWriteDbInfoAsync(string scEquipment, string objectType)
        {
            return await _IScGetWMSTaskService.ScGetPlcWriteDbInfoAsync(scEquipment, objectType);
        }

        /// <summary>
        /// 入库结束任务
        /// </summary>
        /// <param name="scCode"></param>
        /// <returns></returns>
        public async Task<WMSApiDomain.WebApi.HeaderResult<bool>> WCSInEndTaskWork(long wmsTaskCode, string container, string equipment)
        {
            return await _IScGetWMSTaskService.WCSInEndTaskWork(wmsTaskCode, container, equipment);
        }

        /// <summary>
        /// 入库结束任务
        /// </summary>
        /// <param name="scCode"></param>
        /// <returns></returns>
        public async Task<bool> WCSInEndTaskWork(long wmsTaskCode)
        {
            return await _IScGetWMSTaskService.WCSInEndTaskWork(wmsTaskCode);
        }


        /// <summary>
        /// 出库释放货位
        /// </summary>
        /// <param name="scCode"></param>
        /// <returns></returns>
        public async Task<WMSApiDomain.WebApi.HeaderResult<bool>> WCSOutTaskWork(long wmsTaskCode)
        {
            return await _IScGetWMSTaskService.WCSOutTaskWork(wmsTaskCode);
        }


        /// <summary>
        /// WMS手动解绑通知WCS手动完成任务
        /// </summary>
        /// <param name="unbandinWCS"></param>
        /// <returns></returns>
        public async Task<HeaderResult<bool>> WMSManualUnbindingNotificationAsync(UnbandinWCS unbandinWCS)
        {
            return await _IScGetWMSTaskService.WMSManualUnbindingNotificationAsync(unbandinWCS);
        }


        /// <summary>
        /// 模拟交互获取WMS任务
        /// </summary>
        /// <param name="containerBarcode"></param>
        /// <param name="equipment"></param>
        /// <returns></returns>
        public async Task<bool> GetWarehouseWMSTaskAsync(string containerBarcode, string equipment)
        {
            return await _WorkTaskInfoServeice.GetWarehouseWMSTaskAsync(containerBarcode, equipment);
        }

    }
}
